﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using MusicBrowser.Providers;

//namespace MusicBrowser.Metadata.LastFM
//{
//    class NowPlayingService
//    {
//        public struct NowPlayingDTO
//        {
//            public string track;
//            public string artist;
//            public string album;
//            public string mbid;
//            public Int32 duration;
//            public string sessionKey;
//        }

//        public static void DoService(ref NowPlayingDTO DTO)
//        {
//            //Now Playing track.updateNowPlaying
//            //track (Required) : The track name.
//            //artist (Required) : The artist name.
//            //album (Optional) : The album name.
//            //albumArtist (Optional) : The album artist - if this differs from the track artist.
//            //context (Optional) : Sub-client version (not public, only enabled for certain API keys)
//            //trackNumber (Optional) : The track number of the track on the album.
//            //mbid (Optional) : The MusicBrainz Track ID.
//            //duration (Optional) : The length of the track in seconds.
//            //api_key (Required) : A Last.fm API key.
//            //api_sig (Required) : A Last.fm method signature. See authentication for more information.
//            //sk (Required) : A session key generated by authenticating a user via the authentication protocol.

//            if (String.IsNullOrEmpty(DTO.track) || String.IsNullOrEmpty(DTO.artist))
//            {
//                Logging.LoggerFactory.SelectedLogger.LogInfo("Track is missing info required to update Last.FM");
//                return;
//            }

//            TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
//            Int32 unixTime = (Int32)ts.TotalSeconds - (DTO.duration / 2);

//            LastFMProvider.LFMRequest request = new LastFMProvider.LFMRequest();
//            request.RequiresSignature = true;
//            request.Params = new SortedDictionary<string, string>();
//            request.Params.Add("method", "track.updateNowPlaying");
//            request.Params.Add("track", DTO.track);
//            request.Params.Add("timestamp", unixTime.ToString());
//            request.Params.Add("artist", DTO.artist);
//            request.Params.Add("album", DTO.album);
//            request.Params.Add("mbid", DTO.mbid);
//            request.Params.Add("duration", DTO.duration.ToString());
//            request.Params.Add("sk", DTO.sessionKey);

//            try
//            {
//                LastFMProvider.AccessLastFM(request);
//            }
//            catch { }
//        }
//    }
//}